package com.example.esdemo.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Document(indexName = "news_index")
public class News {
    @Id   //映射id
    private String id;
    @Field(type = FieldType.Keyword)
    private String title;
    @Field(type = FieldType.Keyword)
    private String source;
    @Field(value = "record_date", type = FieldType.Date, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date recordDate;
    @Field(type = FieldType.Text, analyzer = "ik_max_word_pinyin", searchAnalyzer = "ik_max_word")
    private String content;
    @Field(type = FieldType.Keyword)
    private String author;
}
